Formatting messages.md
ASCII text
Formatting messages
Formatting in 30 seconds
To format messages you use special syntax.
*italic*
or_italic_
becomes italic.**bold**
or__bold__
becomes bold.~~strikethrough~~
becomesstrikethrough.++inserted++
becomes inserted.--deleted--
becomesdeleted.[link](https://wikipedia.org)
becomes link.![image alt](https://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Crashing_wave.jpg/800px-Crashing_wave.jpg)
becomes .`code`
becomescode
.Paragraphs are separated by a blank line.
~~~
or~~~language
starts a code block;~~~
ends it.#
starts a heading. The number of#
s determines the level.>
starts a blockquote.*
or<number>.
starts a list item.;
makes a comment.A backslash at the end of a line forces a line break.
Introduction
The roundabout uses a markdown-like syntax to format messages, including commit messages, comments, descriptions, files and so on.
It is designed to be similar in philosophy to markdown, and for markdown users it should be really similar (this is why we use Markdown's extension and mime types provisionally, until there is more adoption).
Currently not all markdown (as described in Gruber's initial release) features are supported, but the most common use cases should be covered. Conversely, some extra features are available, primarily ones useful in a code review environment. Some special cases are handled differently compared to Gruber's markdown.
Very importantly, it is not CommonMark compliant!
There is also not a formalised specification for the syntax; first we need to stabilise it.
The syntax does not specify a particular output format, but the reference implementation shipped here outputs HTML.
Philosophy
Like the original markdown, the goal with this syntax is to make it possible to writeplain text that has formatting as a bonus when it's supported.
A document should be readable and publishable even if a rendered version is not available, in its raw form, without looking like it's been marked up with tags or formatting instructions.
Easy to read: The syntax should be understandable enough so that it is readable without rendering it, even for someone not familiar with this syntax.
Easy to write: The syntax should be easy to write using a regular keyboard, only in plain text. The renderer will try its best to understand the human.
However, it should be still easy to read. The syntax should look like what it represents, even if it's a little harder to write it.
Predictable: Edge-cases should be avoided as much as possible, as long as it still understands the writer's intent.
Easy (and fast) to render: A reasonably fast renderer should be possible to write with a reasonable amount of effort and a few lines of code in a high-level language.
Unambiguous: There should not be confusion in parsing. Precedence should be clear, and it should always prioritise the most likely interpretation.
Extensible: Without breaking forward compatibility, it should be possible to add new features to the syntax programmatically, including special interest features like charts, sheet music, or code review features.
Semantic: Available features should never imply altering the document's presentation, but rather its structure and meaning. Clients could style all features as they wish, as long as they reasonably make sense. Allowing the user to add stylesheets is fine, as long as the document itself doesn't contain any style information, and they're not mandatory.
Secure: The syntax should not allow for arbitrary code execution, or any other security risk. It should be safe to render untrusted documents.
Familiar and traditional: Users should be able to learn it in a few minutes, it should be similar to markdown, and follow traditions rooted in plain text mediums, such as email, Usenet, IRC or typewriters.
Structure and terminology
A document is a sequence ofblocks_. Many blocks, but not all, can contain other _child blocks too. Most blocks can hold content, in which case they can also hold _inline elements_.
Most inline elements can hold other inlines as well, but they can't hold blocks.
Some elements, both blocks and inlines, can have _attributes_. Generally this is specified in a clear way in the syntax.
Any sequence of characters is a valid document.
Blocks
Void
A void is just a blank line (appears white, i.e. is empty or only has spaces). It is used to force block separation and is not output in the rendered document.
block 1 block 2
turns into
block 1
block 2
Comment
If a line starts with ;
, it is turned into a void, to allow the writer to
add comments to the document. This is not output in the rendered document,
like any other void. It also separates blocks.
block 1 ; this is a comment block 2
turns into
block 1
block 2
Plain text mediums haven't got a tradition of leaving comments. But the
character ;
was used as it is very unlikely to appear at the start of a
line.
The space is not required. The line just has to begin with a semicolon.
Paragraph
Anything not recognised as another block is considered a paragraph. You can use voids to separate paragraphs. Within a paragraph, whitespace is collapsed like in HTML, so any sequence of spaces will become one space, and newlines will be ignored, although the rendered output can automatically wrap lines.
To force a line break in a paragraph, end the line with a backslash.
Important:\ Unlike in standard markdown, two trailing spaces do not force a line break. That syntax is often considered confusing: in most editors, trailing spaces are invisible.
Instead, use a backslash at the end of the line.
This is a paragraph. This is a new line in the same paragraph. It doesn't wrap, unless you force it to.\ Now it wraps. This is a new paragraph.
turns into
This is a paragraph. This is a new line in the same paragraph. It doesn't wrap, unless you force it to.\ Now it wraps.
This is a new paragraph.
Paragraphs can't contain other blocks because it wouldn't make sense, but they can contain inline elements.
When a block that can contain other blocks has plain text, it is automatically a paragraph, since the parsing is recursive.
Heading
ATX-style heading
ATX-style headings are lines which start with one or more #
, then a space.
The number of #
s determines the heading level.
For H1 you would use
#
.For H2 you would use
##
.For H3 you would use
###
.For H4 you would use
####
.For H5 you would use
#####
.For H6 you would use
######
.
# Heading 1 ## Heading 2 ### Heading 3 #### Heading 4 ##### Heading 5 ###### Heading 6
turns into
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Important:\ Unlike in standard markdown, a space after the
#
is required. This is because it is more readable and less likely to convert unintended sequences of#
s into headings. Additionally, markdown had a rarely-used feature that allowed closing headers with#
s, which is not supported here.
Setext-style heading
Setext headings are only available for H1 and H2. To create an H1,
underline it with =
, and to create an H2, underline it with -
.
Heading 1 ========= Heading 2 ---------
turns into
Heading 1
Heading 2
The number of underlines doesn't matter; you can even use just one. However, it looks nicer if you match the width of the heading. I personally prefer this style where available as it gives more visual weight to the heading and matches traditions.
All headings are single-line. Headings cannot contain other blocks, but they can contain inline elements.
Fence (code block)
A fence is a block that starts and ends with either ```
or ~~~
. Generally it is used for program code.
After the opening fence, on the same line, there can be a language descriptor. Usually it is used to apply syntax highlighting to the code inside, but it could be used for other purposes.
turns into ```text This is a code block.
The language descriptor is optional. If it is not present, the renderer should not apply syntax highlighting, and the block is assumed to be plain text.
Obviously, since the fence contains text that should be rendered specially, it can't contain any other blocks or inlines.
Indented code blocks are currently not supported, but they might be in the future.
Blockquote
A blockquote is a block that starts with >
. It is used to quote
other text, or to set aside text that is not part of the main
content.
A space after the >
is not required, but recommended for
readability.
Blockquotes can contain other blocks, but not inlines. If you want inlines they will be in a paragraph anyways.
> This is a blockquote. > It can contain multiple lines. > ## And even other blocks. > > And they can be nested. > And you can be lazy. > > If this isn't what you want, it can have voids too.
turns into
This is a blockquote. It can contain multiple lines.
And even other blocks.
And they can be nested. And you can be lazy.
If this isn't what you want, it can have voids too.
List
A list is a sequence of list items. List items are represented by lines
that start with *
, +
, or -
, followed by a space, or with a number
followed by a period. The first type creates a bullet (unordered) list,
and the second type creates a numbered (ordered) list. For ordered lists,
the number doesn't matter; it always begins from 1 in HTML.
List items can contain other blocks.
A list item can have continuation lines and contain multiple blocks. Continuation lines are indented with _two spaces_.
Important:\ Unlike in standard markdown, a space after the
*
,+
or-
is required. Also unlike in standard markdown, parsing works normally inside list items, but they must be indented with two spaces, not four. This is because it looks nicer with unordered lists:* This is a list item. This is a continuation line. ; this version vs. * This is a list item. This is a continuation line. ; real markdown
Horizontal rule
A horizontal rule is a line that contains only hyphens, underscores, or asterisks, and optionally spaces. The length must be at least 3.
--------------- ________ * * *
turns into
Summary of blocks
Void: blank line, or line starting with
;
, empty and not output.Paragraph: anything not recognised as another block, can contain
Heading: prefix with
#
or underline, single-line, can containFence: code block, starts and ends with
~~~
or```
,Blockquote: starts with
>
, can contain other blocks with recursiveList: starts with
*
,+
,-
, or<number>.
, continuation linesHorizontal rule: line with at least 3 characters, hyphens,
Inline elements
Text
Technically not an inline element, represented by a simple text in the output. Anything not otherwise recognised is text.
Emphasis
Emphasis is represented by *
or _
surrounding the text. When using _
,
the emphasis must be surrounded by spaces or start/end of the line.
There can be at most 7 markers on each side, the number of opening markers must be exactly the same as the number of closing markers, and they cannot be mixed, unlike in standard markdown. (Maybe this will change in the future, but we'll see.) However mixing them sometimes works, only when nesting makes sense.
The number of markers is interpreted as a sum of powers of 2. If it's 4 or more then there's the third level of emphasis, if the remainder is 2 or more then there's the second level of emphasis, and if there's a remainder then there's the first level of emphasis. You can see how they look below:
level 1
level 2
level 1+2
level 3
level 1+3
level 2+3
level 1+2+3
Strikethrough
Strikethrough is represented by ~~
surrounding the text.
Diff marker
Diff markers are represented by ++
on either side of the text for inserted
text and --
for deleted text.
Link
Links are represented by [text](url)
. The text can contain inline elements.
Title attributes are currently not supported, but they will be.
Image
Images are represented by ![alt text](url)
.
Code
Code is represented by `
surrounding the text.
Using two backticks is not currently supported.
Summary of inline elements
Text: anything not recognised as another inline element.
Emphasis:
*
or_
surrounding the text, at most 7 markers on each side.Strikethrough:
~~
surrounding the text.Diff marker:
++
or--
surrounding the text.Link:
[text](url)
, text can contain inline elements.Image:
![alt text](url)
.Code:
`
surrounding the text.
1Formatting messages 2=================== 3 4Formatting in 30 seconds 5------------------------ 6 7To format messages you use special syntax. 8 9* `*italic*` or `_italic_` becomes *italic*. 10* `**bold**` or `__bold__` becomes **bold**. 11* `~~strikethrough~~` becomes ~~strikethrough~~. 12* `++inserted++` becomes ++inserted++. 13* `--deleted--` becomes --deleted--. 14* `[link](https://wikipedia.org)` becomes [link](https://wikipedia.org). 15* `![image alt](https://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Crashing_wave.jpg/800px-Crashing_wave.jpg)` 16becomes ![image alt](https://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Crashing_wave.jpg/800px-Crashing_wave.jpg). 17* ``code`` becomes `code`. 18* Paragraphs are separated by a blank line. 19* `~~~` or `~~~language` starts a code block; `~~~` ends it. 20* `#` starts a heading. The number of `#`s determines the level. 21* `>` starts a blockquote. 22* `*` or `<number>. ` starts a list item. 23* `;` makes a comment. 24* A backslash at the end of a line forces a line break. 25 26Introduction 27------------ 28 29The roundabout uses a markdown-like syntax to format messages, including 30commit messages, comments, descriptions, files and so on. 31 32It is designed to be similar in philosophy to markdown, and for markdown 33users it should be really similar (this is why we use Markdown's extension 34and mime types provisionally, until there is more adoption). 35 36Currently not all markdown (as described in Gruber's initial release) 37features are supported, but the most common use cases should be covered. 38Conversely, some extra features are available, primarily ones useful in 39a code review environment. Some special cases are handled differently 40compared to Gruber's markdown. 41 42Very importantly, it is *******not******* CommonMark compliant! 43 44There is also not a formalised specification for the syntax; first we need 45to stabilise it. 46 47The syntax does not specify a particular output format, but the reference 48implementation shipped here outputs HTML. 49 50Philosophy 51---------- 52 53Like the original markdown, the goal with this syntax is to make it possible 54to write _plain_ text that has formatting as a bonus when it's supported. 55 56A document should be readable and publishable even if a rendered version is 57not available, in its raw form, without looking like it's been marked up 58with tags or formatting instructions. 59 60* **Easy to read:** The syntax should be understandable enough 61so that it is readable without rendering it, even for someone not familiar 62with this syntax. 63* **Easy to write:** The syntax should be easy to write using a 64regular keyboard, only in plain text. The renderer will try its best to 65understand the human. 66* However, it should be still easy to read. The syntax should look like 67what it represents, even if it's a little harder to write it. 68* **Predictable:** Edge-cases should be avoided as much as 69possible, as long as it still understands the writer's intent. 70* **Easy (and fast) to render:** A reasonably fast renderer should 71be possible to write with a reasonable amount of effort and a few lines of 72code in a high-level language. 73* **Unambiguous:** There should not be confusion in parsing. 74Precedence should be clear, and it should always prioritise the most likely 75interpretation. 76* **Extensible:** Without breaking forward compatibility, it should 77be possible to add new features to the syntax programmatically, including 78special interest features like charts, sheet music, or code review features. 79* **Semantic:** Available features should never imply altering 80the document's presentation, but rather its structure and meaning. Clients 81could style all features as they wish, as long as they reasonably make sense. 82Allowing the user to add stylesheets is fine, as long as the document itself 83doesn't contain any style information, and they're not mandatory. 84* **Secure:** The syntax should not allow for arbitrary code execution, or any 85other security risk. It should be safe to render untrusted documents. 86* **Familiar and traditional**: Users should be able to learn it in a few minutes, 87it should be similar to markdown, and follow traditions rooted in plain text 88mediums, such as email, Usenet, IRC or typewriters. 89 90Structure and terminology 91------------------------- 92 93A document is a sequence of _blocks_. Many blocks, but not all, can contain other 94_child_ blocks too. Most blocks can hold content, in which case they can also hold 95_inline elements_. 96 97Most inline elements can hold other inlines as well, but they can't hold blocks. 98 99Some elements, both blocks and inlines, can have _attributes_. Generally this is 100specified in a clear way in the syntax. 101 102Any sequence of characters is a valid document. 103 104Blocks 105------ 106 107### Void 108A void is just a blank line (appears white, i.e. is empty or only has spaces). 109It is used to force block separation and is not output in the rendered document. 110 111~~~ 112block 1 113 114block 2 115~~~ 116 117turns into 118 119block 1 120 121block 2 122 123#### Comment 124If a line starts with `;`, it is turned into a void, to allow the writer to 125add comments to the document. This is not output in the rendered document, 126like any other void. It also separates blocks. 127 128~~~ 129block 1 130; this is a comment 131block 2 132~~~ 133 134turns into 135 136block 1 137; this is a comment 138block 2 139 140Plain text mediums haven't got a tradition of leaving comments. But the 141character `;` was used as it is very unlikely to appear at the start of a 142line. 143 144The space is not required. The line just has to begin with a semicolon. 145 146### Paragraph 147Anything not recognised as another block is considered a paragraph. You can 148use voids to separate paragraphs. Within a paragraph, whitespace is collapsed 149like in HTML, so any sequence of spaces will become one space, and newlines 150will be ignored, although the rendered output can automatically wrap lines. 151 152To force a line break in a paragraph, end the line with a backslash. 153 154> **Important:**\ 155> Unlike in standard markdown, two trailing spaces do not force a line break. 156> That syntax is often considered confusing: in most editors, trailing spaces 157> are invisible. 158> 159> Instead, use a backslash at the end of the line. 160 161~~~ 162This is a paragraph. 163This is a new line in the same paragraph. 164It doesn't wrap, unless you force it to.\ 165Now it wraps. 166 167This is a new paragraph. 168~~~ 169 170turns into 171 172This is a paragraph. 173This is a new line in the same paragraph. 174It doesn't wrap, unless you force it to.\ 175Now it wraps. 176 177This is a new paragraph. 178 179Paragraphs can't contain other blocks because it wouldn't make sense, but 180they can contain inline elements. 181 182When a block that can contain other blocks has plain text, it is 183automatically a paragraph, since the parsing is recursive. 184 185### Heading 186#### ATX-style heading 187ATX-style headings are lines which start with one or more `#`, then a space. 188The number of `#`s determines the heading level. 189 190* For H1 you would use `#`. 191* For H2 you would use `##`. 192* For H3 you would use `###`. 193* For H4 you would use `####`. 194* For H5 you would use `#####`. 195* For H6 you would use `######`. 196 197~~~ 198# Heading 1 199## Heading 2 200### Heading 3 201#### Heading 4 202##### Heading 5 203###### Heading 6 204~~~ 205 206turns into 207 208# Heading 1 209## Heading 2 210### Heading 3 211#### Heading 4 212##### Heading 5 213###### Heading 6 214 215> **Important:**\ 216> Unlike in standard markdown, a space after the `#` is required. 217> This is because it is more readable and less likely to convert 218> unintended sequences of `#`s into headings. 219> Additionally, markdown had a rarely-used feature that allowed 220> closing headers with `#`s, which is not supported here. 221 222#### Setext-style heading 223Setext headings are only available for H1 and H2. To create an H1, 224underline it with `=`, and to create an H2, underline it with `-`. 225 226~~~ 227Heading 1 228========= 229 230Heading 2 231--------- 232~~~ 233 234turns into 235 236Heading 1 237========= 238 239Heading 2 240--------- 241 242The number of underlines doesn't matter; you can even use just one. 243However, it looks nicer if you match the width of the heading. 244I personally prefer this style where available as it gives more visual 245weight to the heading and matches traditions. 246 247All headings are single-line. Headings cannot contain other blocks, 248but they can contain inline elements. 249 250### Fence (code block) 251A fence is a block that starts and ends with either ````` 252or `~~~`. Generally it is used for program code. 253 254After the opening fence, on the same line, there can be a language 255descriptor. Usually it is used to apply syntax highlighting to the 256code inside, but it could be used for other purposes. 257 258~~~ 259```text 260This is a code block. 261``` 262~~~ 263 264turns into 265 266```text 267This is a code block. 268``` 269 270The language descriptor is optional. If it is not present, the 271renderer should not apply syntax highlighting, and the block is 272assumed to be plain text. 273 274Obviously, since the fence contains text that should be rendered 275specially, it can't contain any other blocks or inlines. 276 277Indented code blocks are currently not supported, but they might 278be in the future. 279 280### Blockquote 281A blockquote is a block that starts with `>`. It is used to quote 282other text, or to set aside text that is not part of the main 283content. 284 285A space after the `>` is not required, but recommended for 286readability. 287 288Blockquotes can contain other blocks, but not inlines. If you want 289inlines they will be in a paragraph anyways. 290 291~~~ 292> This is a blockquote. 293> It can contain multiple lines. 294> ## And even other blocks. 295> > And they can be nested. 296> And you can be lazy. 297> 298> If this isn't what you want, it can have voids too. 299~~~ 300 301turns into 302 303> This is a blockquote. 304> It can contain multiple lines. 305> ## And even other blocks. 306> > And they can be nested. 307> And you can be lazy. 308> 309> If this isn't what you want, it can have voids too. 310 311### List 312A list is a sequence of list items. List items are represented by lines 313that start with `*`, `+`, or `-`, followed by a space, or with a number 314followed by a period. The first type creates a bullet (unordered) list, 315and the second type creates a numbered (ordered) list. For ordered lists, 316the number doesn't matter; it always begins from 1 in HTML. 317 318List items can contain other blocks. 319 320A list item can have continuation lines and contain multiple blocks. 321Continuation lines are indented with _two spaces_. 322 323> **Important:**\ 324> Unlike in standard markdown, a space after the `*`, `+` or `-` is 325> required. 326> Also unlike in standard markdown, parsing works normally inside 327> list items, but they must be indented with two spaces, not four. 328> This is because it looks nicer with unordered lists: 329> ~~~ 330> * This is a list item. 331> This is a continuation line. 332> ; this version vs. 333> * This is a list item. 334> This is a continuation line. 335> ; real markdown 336> ~~~ 337 338### Horizontal rule 339A horizontal rule is a line that contains only hyphens, underscores, 340or asterisks, and optionally spaces. The length must be at least 3. 341 342~~~ 343--------------- 344 345________ 346 347* * * 348~~~ 349 350turns into 351 352--------------- 353 354________ 355 356* * * 357 358### Summary of blocks 3591. **Void:** blank line, or line starting with `;`, empty and not output. 3602. **Paragraph:** anything not recognised as another block, can contain 361inline elements but not blocks. 3623. **Heading:** prefix with `#` or underline, single-line, can contain 363inline elements. 3644. **Fence:** code block, starts and ends with `~~~` or `````, 365can contain only text, optionally with a language descriptor. 3665. **Blockquote:** starts with `>`, can contain other blocks with recursive 367parsing. 3686. **List:** starts with `*`, `+`, `-`, or `<number>.`, continuation lines 369are indented with two spaces, can contain other blocks with recursive 370parsing. 3717. **Horizontal rule:** line with at least 3 characters, hyphens, 372underscores, or asterisks, optionally with spaces. 373 374Inline elements 375--------------- 376 377### Text 378Technically not an inline element, represented by a simple text in the 379output. Anything not otherwise recognised is text. 380 381### Emphasis 382Emphasis is represented by `*` or `_` surrounding the text. When using `_`, 383the emphasis must be surrounded by spaces or start/end of the line. 384 385There can be at most 7 markers on each side, the number of opening markers 386must be exactly the same as the number of closing markers, 387and they cannot be mixed, unlike in standard markdown. (Maybe this will change 388in the future, but we'll see.) However mixing them sometimes works, only when 389nesting makes sense. 390 391The number of markers is interpreted as a sum of powers of 2. If it's 4 or 392more then there's the third level of emphasis, if the remainder is 2 or more 393then there's the second level of emphasis, and if there's a remainder then 394there's the first level of emphasis. You can see how they look below: 395 3961. *level 1* 3972. **level 2** 3983. ***level 1+2*** 3994. ****level 3**** 4005. *****level 1+3***** 4016. ******level 2+3****** 4027. *******level 1+2+3******* 403 404### Strikethrough 405Strikethrough is represented by `~~` surrounding the text. 406 407### Diff marker 408Diff markers are represented by `++` on either side of the text for inserted 409text and `--` for deleted text. 410 411### Link 412Links are represented by `[text](url)`. The text can contain inline elements. 413Title attributes are currently not supported, but they will be. 414 415#### Image 416Images are represented by `![alt text](url)`. 417 418### Code 419Code is represented by ``` surrounding the text. 420Using two backticks is not currently supported. 421 422### Summary of inline elements 4231. **Text:** anything not recognised as another inline element. 4242. **Emphasis:** `*` or `_` surrounding the text, at most 7 markers on each side. 4253. **Strikethrough:** `~~` surrounding the text. 4264. **Diff marker:** `++` or `--` surrounding the text. 4275. **Link:** `[text](url)`, text can contain inline elements. 4286. **Image:** `![alt text](url)`. 4297. **Code:** ``` surrounding the text. 430